package com.bestdreamer.thread_join;

public class Demo2ThreadA extends Thread {

    private final Demo2ThreadB threadB;

    public Demo2ThreadA(Demo2ThreadB threadB){
        super();
        this.threadB = threadB;
    }

    @Override
    public void run() {
        try{
            synchronized (threadB){
                System.out.println("begin A ThreadName = " + Thread.currentThread().getName() + " " + System.currentTimeMillis());
                Thread.sleep(5000);
                System.out.println(" end A ThreadName = " + Thread.currentThread().getName() + " " + System.currentTimeMillis());
            }
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }
}
